{include file='public/header.html'}
<link href="__STATIC__/cherry/cherry-markdown.min.css" rel="stylesheet">
<style>
    #markdown-editor {
        width: 100%;
        margin: 0 auto;
        min-height: 500px;
        border: 1px solid #ddd;
    }
</style>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar" id="sidebar">
            {include file='public/sidebar.html'}
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" id="main">
            <h3 class="page-header">修改文档</h3>

            <div class="panel panel-default">
                <div class="panel-heading">修改文档 - {$book_id|get_book_name}<span class="pull-right"><a href="javascript:history.back(-1);">返回</a></span></div>
                <div class="panel-body">
                    <form class="form-horizontal submit-ajax" role="form" action="{:url('edit')}" method="post">
                        <input type="hidden" name="id" value="{$vo.id}" />
                        <input type="hidden" name="book_id" value="{$book_id}"/>

                        <div class="form-group">
                            <label for="pid" class="col-sm-1 control-label">*上级</label>
                            <div class="col-sm-11">
                                {:form_select('pid', widget('common.book_dir')->get($book_id,['get_type'=>1]), $vo['pid'], ' class="form-control" style="width:200px;"')}
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-sm-1 control-label">*标题</label>
                            <div class="col-sm-11">
                                <input type="text" id="title" name="title" class="form-control" placeholder="请输入文档标题" value="{$vo.title}" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="sign" class="col-sm-1 control-label">*标识</label>
                            <div class="col-sm-11">
                                <input type="text" id="sign" name="sign" class="form-control" placeholder="标识名称(下载用)" value="{$vo.sign}" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">*内容</label>
                            <div class="col-sm-11">
                                <div id="markdown-editor"></div>
                                <textarea id="markdown-content" name="markdown" style="display: none;">{$vo.markdown}</textarea>
                                <textarea id="html-content" name="html" style="display: none;"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="summary" class="col-sm-1 control-label">摘要</label>
                            <div class="col-sm-11">
                                <textarea name="summary" id="summary" rows="2" class="form-control" placeholder="文档摘要，为空自动获取">{$vo.summary}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="sort" class="col-sm-1 control-label">*排序</label>
                            <div class="col-sm-11">
                                <input type="text" id="sort" name="sort" class="form-control" placeholder="排序值(越小排越前)" value="{$vo.sort}" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="ver_int" class="col-sm-1 control-label">更新版本</label>
                            <div class="col-sm-11">
                                <input type="text" id="ver_int" name="ver_int" class="form-control" placeholder="更新版本号(整数)" value="{$vo.ver_int}" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="change_desc" class="col-sm-1 control-label">更新描述</label>
                            <div class="col-sm-11">
                                <textarea id="change_desc" name="change_desc" class="form-control" placeholder="更变文档时存入历史：新版本号大于旧版本号或不同编辑者更新"></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-1 control-label">&nbsp;</label>
                            <div class="col-sm-11">
                                <input type="submit" id="submit" value="修改" class="btn btn-primary" />
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{include file='public/footer.html'}
<script>
    const GV = {
        upload_api: "{:url('api/upload')}",
        pic_upload_api: "{:url('api/upload_base64')}",
        pic_del_api: "{:url('api/image_del')}",
    }
</script>
<script src="__STATIC__/cherry/cherry-markdown.core.js"></script>
<script src="__STATIC__/js/cherry_editor.js?v={:site_ver()}"></script>
<script>
    $(function () {
        let content = $('#markdown-content').text();
        editor.setMarkdown(content);
    });
</script>
</body>
</html>